package com.javabasic2.pjchatserver;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Question {
	private ArrayList<String> questionList;
	public void setQuestionList(ArrayList<String> questionList) {
		this.questionList = questionList;
	}
	public Question() {
		questionList = new ArrayList<String>(); 
		createQustion();
	}
	private void createQustion(){
		File file = new File("quest.txt");
		if (file.exists()) {
			try {
				BufferedReader inFile = new BufferedReader(new InputStreamReader(new FileInputStream(file),"EUC-KR"));
				String sLine = null;
				while ((sLine = inFile.readLine()) != null) {
					questionList.add(sLine);
					
				}
				inFile.close();
			} catch (IOException e) {
				e.printStackTrace();	
			}
		}
	}
	public String getRandomQuestion(int i) {
		return questionList.get(i);
	}
}
